<?php
/**
 * Created by JetBrains PhpStorm.
 * User: linhpv
 * Date: 2/18/14
 * Time: 7:46 PM
 * To change this template use File | Settings | File Templates.
 */
class ValidatePrice extends CValidator
{
    public $attribute2;

    protected function validateAttribute($object, $attribute)
    {

        $value1 = isset($object->$attribute) ? $object->$attribute : 0;
        $object->$attribute=$value1;
        $attributeTmp = $this->attribute2;
        $value2 = isset($object->$attributeTmp) ? $object->$attributeTmp : 0;
        $object->$attributeTmp=$value2;
        if ($value1 == 0 && $value2 == 0) {
            $this->addError($object, $attribute,  'Partial price  must be smaller than  full price ' );
        } else if ($value1 > 0 && $value2 > 0) {
            if ($value1 >= $value2) {
                $this->addError($object, $attribute, 'Partial price  must be smaller than  full price ');
            }
        }
        else if($value1<0)
        {
            $this->addError($object, $attribute, 'Partial price  must be over than 0');
        }
        else if($value2<0)
        {
            $this->addError($object, $this->attribute2, 'Full price must be over than 0');
        }

    }

}

?>